' Based on  "Cardioid and Beyond" 'B+ 2019-02-17 (https://qb64phoenix.com/forum/showthread.php?tid=162&pid=14121#pid14121)
' BASIC Anywhere Machine program by Charlie Veniot

Const xmax = 400
Const ymax = 400
Const npoints = 200
Screen _NewImage(xmax, ymax, 27)
Dim as double pR, pG, pB, cN, CX, CY, DA, R, temp, Mult, Mult_inc
CX = xmax / 2
CY = ymax / 2
DA = _Pi(2 / npoints)
R = CX - 10
Mult_inc = .0075
Mult_max = 6
Mult_min = 0

DECLARE SUB resetPlasma ()
Mult = 0
do
    Cls
    Color &HFFFFFF
    If Mult = Int(Mult) Then resetPlasma 
    Circle (CX, CY), R, _RGB32(0, 128, 0)
    For i = 0 To 777 step 1
        x1 = cint(CX + R * Cos(i * DA))
        y1 = cint(CY + R * Sin(i * DA))
        temp = Mult * i * DA
        x2 = cint(CX + R * Cos(temp))
        y2 = cint(CY + R * Sin(temp))
        cN = cN + 1        
        Line (x1, y1)-(x2, y2), _RGB((127 + int( 127 * Sin(pR * cN))) mod 256, (127 + int(127 * Sin(pG * cN))) mod 256, (127 + int(127 * Sin(pB * cN))) mod 256)
    Next
'    _display
    _delay 0.075
    if _mousebutton then while _mousebutton : wend
Mult = Mult + Mult_inc
if Mult > Mult_max or Mult < 0 then Mult_inc = - Mult_inc
loop

Sub resetPlasma ()
    pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2
End Sub